<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    用户名称   ：        <input type="text" id="ipt-text" value=""><span></span><br><br>
    登录密码    ：        <input type="text" id="ipt-list" value=""><span></span><br><br>
               <input type="button"id="btn" value="注册">
    <script>
     let ipt1=document.querySelector('#ipt-text')
    let ipt2=document.querySelector('#ipt-list')
    let  btn=document.querySelector('#btn')
     //用户名称
     var bt=false
     ipt1.onfocus=function(){
          var a=/^[a-zA-Z]\w{6,12}$/
          var res=ipt1.value

          if(a.test(res)==true){
             
          console.log('正确')
            bt=true
            box()
          }
          if(a.test(res)==false){
              console.log('错误')
             ap.innerHTML = "输入有误"
          }
          }

     //用户密码
             var op=false
      ipt2.onfocus=function(){
          var a=/^[a-zA-Z]\w{6,12}$/
          var res=ipt2.value;
          if(a.test(res)==true){
            console.log('正确')
             op=true
             box()
          }
          if(a.test(res)==false){
            console.log('错误')
            ap.innerHTML = "输入有误"
          }
      }
    
    </script>
</body>
</html>